package fsu.cs.cis5930;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Spinner;

/**
 *  This is the activity that the user is first presented. It should contain the game logo, a way to
 *  start the game, and a way to specify the game settings.
 *
 */
public class SettingsActivity extends Activity {
	
	private Settings gameSettings;
	private GameEngine engine;
	private ImageButton	save;
	private EditText x;
	private EditText y;
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.settings);
        Spinner playstyles = (Spinner) findViewById(R.id.spinner1);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                this, R.array.playing_options, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        playstyles.setAdapter(adapter);

        
        engine = (GameEngine) getApplicationContext();
	    gameSettings = engine.getSettings();
        save = (ImageButton) findViewById(R.id.save);
        x = (EditText) findViewById(R.id.x);
        y = (EditText) findViewById(R.id.y);
        
        x.setText( Integer.toString(gameSettings.getMaxX()));
        y.setText( Integer.toString(gameSettings.getMaxY()));
        
        save.setOnClickListener( new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				gameSettings.setMaxX( new Integer(x.getText().toString()));
				gameSettings.setMaxY( new Integer(y.getText().toString()));
				finish();
			}
		});
        
    }
}